{% extends "base.html" %}
{% block content %}
    <p>今日菜价：</p>
<div class="row">
    {% for post in posts %}
    <div class="col-md-12">
        <p>{{ post['goods'] }}, {{ post['notes'] }},{{ post['price'] }}({{ post['unit'] }})</p>
    </div>
    {% if not loop.last %}
    <hr>
    {% endif %}
    {% endfor %}
</div>

<!-- 分页控件 -->
<nav aria-label="Page navigation">
    <ul class="pagination">
        {% if total_pages > 1 %}
            {% if current_page != 1 %}
                <li class="page-item">
                    <a class="page-link" href="{{ url_for('vegetable_baskets', page=1) }}">首页</a>
                </li>
                <li class="page-item">
                    <a class="page-link" href="{{ url_for('vegetable_baskets', page=current_page-1) }}">上一页</a>
                </li>
            {% endif %}

            {% for page_num in range(1, total_pages + 1) %}
                <li class="page-item {% if page_num == current_page %}active{% endif %}">
                    <a class="page-link" href="{{ url_for('vegetable_baskets', page=page_num) }}">{{ page_num }}</a>
                </li>
            {% endfor %}

            {% if current_page != total_pages %}
                <li class="page-item">
                    <a class="page-link" href="{{ url_for('vegetable_baskets', page=current_page+1) }}">下一页</a>
                </li>
                <li class="page-item">
                    <a class="page-link" href="{{ url_for('vegetable_baskets', page=total_pages) }}">末页</a>
                </li>
            {% endif %}
        {% endif %}
    </ul>
</nav>

{% endblock %}